home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / cli / mx2src.arc / ATOMIC.DEF < prev    next >
Text File  |  1989-01-05  |  15KB  |  305 lines

  1. DEFINITION MODULE ATOMIC;
  2.  
  3. (*              Copyright 1987,1988 fred brooks LogicTek        *)
  4. (*                                                              *)
  5. (*                                                              *)
  6. (*   First Release                      12/8/87-FGB             *)
  7. (* Added variable parm to StartProcess to pass info to process  *)
  8. (* in currentprocess.gemsave[15]        1/1/88-FGB              *)
  9. (*                                                              *)
  10. (* Remove monitor priority. Each routine the switches processes *)
  11. (* must be protected from all interrupts by the IntEnd and      *)
  12. (* IntBegin calls. If this is not done correctly the system     *)
  13. (* system will bomb.                    4/4/88-FGB              *)
  14. (*                                                              *)
  15.  
  16. FROM    SYSTEM  IMPORT  ADDRESS,BYTE;
  17. FROM    NEWSYS  IMPORT  PROCESS;
  18. FROM    Strings IMPORT  String;
  19.  
  20. CONST   MAGIC            =       22261; (* somebodys b-day *)
  21.         buflength        =       1024;
  22.         OTOS             =       LONGCARD(602CH); (* Old rom TOS *)
  23.         MTOS             =       LONGCARD(87CEH); (* New rom MEGA TOS *)
  24.         OLDDATE          =       11201985H;
  25.         NEWDATE          =       04221987H;
  26.         VERSION          =       "  MX2 V2.3.0"; (* mx2 version number *)
  27. TYPE
  28.         Gvectype        =       POINTER TO ADDRESS;
  29.         buffer  =       ARRAY [0..buflength] OF BYTE;
  30.         PIPE    =       RECORD
  31.                 pipename:       String;
  32.                 buf     :       buffer;
  33.                 bufsize :       CARDINAL;
  34.                 bufhead :       CARDINAL;
  35.                 buftail :       CARDINAL;
  36.                 cnt     :       CARDINAL;
  37.         END;
  38.         pipeptr =       POINTER TO PIPE;
  39. (*      these devices are defined for use with the MX2 port command
  40.         dev0 thru dev7 are user defineable device drivers. By loading
  41.         the addresses of the correct procedures into the DeviceTable for
  42.         in, out and status custom devices may be defined.
  43.         DeviceTable[dev0].bconstat:=Mybconstat;
  44.         DeviceTable[dev0].bcostat:=Mybcostat;
  45.         DeviceTable[dev0].bconin:=Mybconin;
  46.         DeviceTable[dev0].bconout:=Mybconout;
  47.         Will setup dev0 for use with the port command.
  48.  
  49.         sys port 4 -0 -0
  50.         will cause the process with the PID of 4 to use dev0
  51. *)
  52.         devicetype =    (printer,aux,con,midi,null,dev0,dev1,dev2,dev3,
  53.                          dev4,dev5,dev6,dev7);
  54.         devstattype     =       PROCEDURE(): BOOLEAN;
  55.         devintype       =       PROCEDURE(): LONGCARD;
  56.         devouttype      =       PROCEDURE(CHAR);
  57.  
  58.         devblocktype    =       RECORD
  59.                 bconstat        :       devstattype;
  60.                 bcostat         :       devstattype;
  61.                 bconin          :       devintype;
  62.                 bconout         :       devouttype;
  63.         END;
  64.         devtabletype    =       ARRAY [ORD(dev0)..ORD(dev7)] OF devblocktype;
  65.  
  66. TYPE            SIGNAL          =       POINTER TO ProcessDescriptor;
  67.                 GEMTYPE         =       ARRAY [0..0FFH] OF ADDRESS;
  68.                 pipetype        =       ARRAY [0..31] OF pipeptr;
  69.         (* pipe names starting with mx2 or MX2 are reserved by the
  70.            system *)
  71. (* This is the control record for all system process. Variable
  72.    "currentprocess" points to the currently running process. The ready
  73.    queue is implemented as a linked list round robin. *)
  74.  
  75. (* The gemsave array contains important system vectors that are switched
  76.    with every process. This allows programs to intercept trap vectors
  77.    such as the GEMDOS TRAP 1 and still to allow the other programs
  78.    to run correctly.       current vectors saved are
  79.                            gemsave[0]      gem workspace pointer
  80.                            gemsave[1]      LINEA   VECTOR    28H
  81.                            gemsave[2]      GEMDOS  TRAP 1    84H
  82.                            gemsave[3]      GSX,GEM TRAP 2    88H
  83.                            gemsave[4]      BIOS    TRAP 13   B4H
  84.                            gemsave[5]      XBIOS   TRAP 14   B8H
  85.                            gemsave[6]      linef   VECTOR    2CH
  86.                            gemsave[7]      level2  VECTOR    68H
  87.                            gemsave[8]      level4  VECTOR    70H
  88.                            gemsave[9]      _shell_p         4F6H
  89.                            gemsave[11]     wait value (* V2.2.0 *)
  90.                            gemsave[12]     wait mask  (* V2.2.0 *)
  91.                            gemsave[13]     sleep timer variable
  92.                            gemsave[14]     timer flag variable
  93.                            gemsave[15]     init parameter for process
  94.  
  95.                            misc[0]         priority work variable
  96. *)
  97.  
  98.         ProcessDescriptor =
  99.                RECORD
  100.                         name    :       String;   (* process name *)
  101.                         pid     :       INTEGER;  (* process id   *)
  102.                         cor     :       PROCESS;  (* process coroutine *)
  103.                         pc      :       ADDRESS;  (* process PC *)
  104.                         sr      :       CARDINAL; (* process SR *)
  105.                         ssp     :       ADDRESS;  (* process super SR *)
  106.                         biosval :       ADDRESS;  (* bios call save ptr *)
  107.                         retval  :       ADDRESS;
  108.                         biosave :       ARRAY [0..225] OF CARDINAL;
  109.                         gemsave :       ARRAY [0..15]  OF ADDRESS; 
  110.                         termvec :       ADDRESS;
  111.                         wsp     :       ADDRESS;  (* process work space *)
  112.                         wspsize :       LONGCARD; (* size of work space *)
  113.                         next    :       SIGNAL;   (* ptr to next process *)
  114.                         ppid    :       INTEGER;  (* parent id *)
  115.                         tmpcor  :       PROCESS;  (* cor save variable *)
  116.                         ready   :       BOOLEAN;  (* process run flag *)
  117.                         active  :       BOOLEAN;  (* process alive flag *)
  118.                         intflag :       BOOLEAN;  (* process switched *)
  119.                         date    :       CARDINAL; (* date started *)
  120.                         time    :       CARDINAL; (* time started *)
  121.                         tick    :       LONGCARD; (* total 200hz clocks *)
  122.                         slice   :       LONGCARD; (* restart time 200hz *)
  123.                         pri     :       INTEGER;  (* set length of run *)
  124.                         flags   :       ARRAY [0..2] OF LONGCARD; (* var *)
  125. (* flags[0] is default drive of process that called the kernel
  126.    flags[1] is address of process to be added to ready list of kernel
  127.    flags[2] is size of process stack or workspace
  128. *)
  129.                         ipname  :       String;   (* program name *)
  130.                         iptail  :       String;   (* program command *)
  131.                       ipenvstr  :       String;   (* program env string *)
  132.                         return  :       INTEGER;  (* function return *)
  133.                         errno   :       INTEGER;  (* error number *)
  134.                         bpsave  :       GEMTYPE;  (* save for gemdos *)
  135.                         Iport   :       devicetype;
  136.                         Oport   :       devicetype;
  137.                         waitloc :       POINTER TO LONGCARD; (* V2.2.0 *)
  138.                         misc    :       ARRAY [0..8] OF INTEGER;
  139.                END;
  140.  
  141. (* Vector 144H points to variable that contains this record *)
  142. (* look at SYS.MOD for an example of use of these variables *)
  143.  
  144.      sysrequesttype =
  145.                RECORD
  146.                   req         : BOOLEAN;
  147.                   pid         : INTEGER;
  148.                   magic       : LONGCARD;
  149.                END;
  150.  
  151.      spinttype =
  152.                RECORD
  153.                   proc        : PROC;
  154.                   pid         : INTEGER;
  155.                   data        : ADDRESS;
  156.                END;
  157.  
  158.      StartProcesstype           = PROCEDURE(VAR PROC,VAR LONGCARD,
  159.                                             VAR INTEGER,VAR String,
  160.                                             VAR ADDRESS);
  161.      SwapProcesstype